import audioop
import base64

import pyaudio
import wave

import requests

chunk = 1024
format = pyaudio.paInt16
channels = 1
rate = 8000
record_seconds = 5
with open("/home/leo/Downloads/1351588881262188643.wav", "rb") as file:
    data = file.read()
    data = audioop.ulaw2lin(data, 2)
    file.close()
    #url = "http://ability.ai.rmd.com.cn/ai/asr"
    #url = "http://ability.ai.rmd.com.cn/book/search"
    url = "http://192.168.102.12:37090/book/search"
    myParams = {"robotId": 6,'cid':'test01', "fs": 8000, "audioData": base64.b64encode(data), 'hotwords': ["michael","parker's"]}
    res = requests.post(url=url, json=myParams)

    print('url:', res.request.url)  # 查看发送的url
    print("response:", res.text)  # 返回请求结果